Skip to content

Fix device mismatch in rotated NMS and visualization on Windows#1099

Open
VISWA00723 wants to merge 1 commit intoopen-mmlab:mainfrom
VISWA00723:fix/windows-redet-nms-device
Open

Fix device mismatch in rotated NMS and visualization on Windows#1099
VISWA00723 wants to merge 1 commit intoopen-mmlab:mainfrom
VISWA00723:fix/windows-redet-nms-device

Conversation

@VISWA00723
Copy link
Copy Markdown

Motivation

ReDet inference on Windows fails due to device mismatches between tensors used in
rotated NMS and visualization code paths. Specifically, indices produced during
NMS may reside on CPU while the corresponding tensors are on GPU (or vice versa),
leading to runtime errors such as:

RuntimeError: indices should be either on cpu or on the same device as the indexed tensor

Additionally, the visualization pipeline may crash when NumPy indices are passed
to tensor .to() calls.

This PR aims to make ReDet inference stable and usable on Windows without
changing model behavior or training logic.

Modification

This PR introduces defensive device alignment during rotated NMS and
visualization:

Ensures index tensors used for indexing are moved to the same device as the
tensors being indexed.

Adds safe handling for NumPy vs torch.Tensor indices during visualization.

No changes to model architecture, weights, or training behavior.

All modifications are minimal, localized, and inference-only.

BC-breaking

No.

This PR does not change public APIs.

No changes to configuration files or model definitions.

Behavior on Linux remains unchanged.

Downstream projects do not need any code changes.

Use cases

Running ReDet inference on Windows + CUDA

Large-image / patch-based inference using
inference_detector_by_patches

Stable rotated bounding box visualization across platforms

Checklist

Linting

Existing code style is preserved.

Changes follow the current MMRotate code patterns.

Unit tests

No existing unit tests cover Windows-specific CUDA/NMS behavior.

The fix was validated through end-to-end inference on Windows.

Adding automated tests is non-trivial due to platform-specific behavior.

Documentation

No documentation updates are required as behavior and APIs are unchanged.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Viswa V R seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants